package com.luban.springcloud.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Component;

import com.luban.springcloud.pojo.User;

import feign.hystrix.FallbackFactory;

@Component
public class UserFeignClientFallbackFactory implements FallbackFactory<UserFeignClientService>{

	@Override
	public UserFeignClientService create(Throwable cause) {
		return new UserFeignClientService() {
			
			@Override
			public List<User> list() {
				return null;
			}
			
			@Override
			public User get(Integer id) {
				User user = new User();
				user.setId(500);
				user.setType("0000");
				user.setUserName("服务提供者发生错误");
				return user;
			}
			
			@Override
			public boolean delete(Integer id) {
				return false;
			}
			
			@Override
			public String addOrUpdateUser(User user) {
				return null;
			}

			@Override
			public Map<String, Object> getServiceInfo() {
				Map<String,Object> map=new HashMap<String,Object>();
                map.put("code", 500);
                map.put("info", "服务提供者发生错误");
                return map;
			}
		};
	}

}
